package com.dnjn.happiness.emo.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.emo.api.RemoteHlbeanTypeService;
import com.dnjn.happiness.emo.api.model.HlbeanTypeVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteHlbeanTypeFallbackFactory implements FallbackFactory<RemoteHlbeanTypeService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteHlbeanTypeFallbackFactory.class);

    @Override
    public RemoteHlbeanTypeService create(Throwable throwable) {
        log.error("调用emoHlbeanType服务失败：" + throwable.getMessage());
        return new RemoteHlbeanTypeService() {
            @Override
            public R<HlbeanTypeVO> getHlbeanTypeByCode(String code, String source) {
                return R.fail("获取Hlbean失败: {}" + throwable.getMessage());
            }
        };
    }
}
